package cn.wolfcode.trip.base.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public abstract class DateUtil {
    //使用SimpleDateFormat修改日期格式
    private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    //将Date类型日期修改成字符串类型
    public static String formatDate(Date date) {
        return format.format(date);
    }
    //通过Calendar类将当前的时间设为23:59:59
    public static Date getEndDate(Date date) {
        if (date == null) {
            return null;
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR,23);
        c.set(Calendar.MINUTE,59);
        c.set(Calendar.SECOND,59);
        return c.getTime();
    }
}
